package io.github.yotta.dict.web.controller;

import io.github.yotta.common.api.model.IdRequest;
import io.github.yotta.common.api.model.Paging;
import io.github.yotta.common.web.extension.TenantResolveProvider;
import io.github.yotta.dict.api.param.SysDictQueryParam;
import io.github.yotta.dict.api.vo.SysDictStatusVo;
import io.github.yotta.dict.api.vo.SysDictVo;
import io.github.yotta.dict.api.service.SysDictService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author yotta-generator
* @date 2025-08-11 10:12:20
* 系统字典表 - 控制器
*/
@SuppressWarnings("unused")
@RestController
@RequestMapping("/sysDict")
@RequiredArgsConstructor
public abstract class SysDictReadController {

    private final SysDictService sysDictService;
    private final TenantResolveProvider tenantResolveProvider;

    @GetMapping()
    public SysDictVo getById(
            HttpServletRequest request,
            IdRequest param) {
        String tenantId = tenantResolveProvider.loadTenantId(request);
        param.setTenantId(tenantId);
        return sysDictService.getById(param);
    }


    @GetMapping("/list")
    public List<SysDictVo> list(
            HttpServletRequest request,
            SysDictQueryParam param) {
        String tenantId = tenantResolveProvider.loadTenantId(request);
        param.setTenantId(tenantId);
        return sysDictService.list(param);
    }

    @GetMapping("/listStatus")
    public List<SysDictStatusVo> list() {
        return sysDictService.listStatus();
    }

    @GetMapping("/page")
    public Paging<SysDictVo> page(HttpServletRequest request, SysDictQueryParam param) {
        String tenantId = tenantResolveProvider.loadTenantId(request);
        param.setTenantId(tenantId);
        return sysDictService.page(param);
    }



}
